package com.tchintech.pay.utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Administrator on 2017/7/6 0006.
 */

public class SPUtils {
    private SharedPreferences sharedPreferences;

    public SPUtils(Context c) {
        sharedPreferences = c.getSharedPreferences(c.getPackageName(),
                Activity.MODE_PRIVATE);
    }




    /**
     * 写String
     *
     * @param key
     * @param value
     */
    public void write(String key, String value) {

        SharedPreferences.Editor editor = sharedPreferences.edit();
        //写入String 数据
        editor.putString(key, value);
        //提交
        editor.apply();
    }

    /**
     * 读String
     *
     * @param key
     * @return
     */
    public String read(String key) {
        return sharedPreferences.getString(key, "");
    }

    /**
     * 删除
     *
     * @param key
     */
    public void remove(String key) {
        sharedPreferences.edit().remove(key).commit();
    }

}
